package com.rzcoding;

import com.rzcoding.filter.AuthorizeFilter;
import com.rzcoding.filter.XssFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import tk.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@MapperScan(basePackages = "com.rzcoding.dao")
public class MallAdminApplication {

	public static void main(String[] args) {
		SpringApplication.run(MallAdminApplication.class, args);
	}

	@Bean
	public FilterRegistrationBean authorizeFilter(){
		FilterRegistrationBean filter = new FilterRegistrationBean(new AuthorizeFilter());
		filter.addUrlPatterns("/api/*");
		filter.setName("authorizeFilter");
		filter.setOrder(1);
		return filter;
	}

	@Bean
	public FilterRegistrationBean xssFilter(){
		FilterRegistrationBean filter = new FilterRegistrationBean(new XssFilter());
		filter.addUrlPatterns("/api/*");
		filter.setName("xssFilter");
		filter.setOrder(2);
		return filter;
	}
}
